//
//  OutOfTimeBuyItemCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2017/12/18.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import "OutOfTimeBuyItemCell.h"

@interface OutOfTimeBuyItemCell ()
@property (weak, nonatomic) IBOutlet UIImageView *topImageView;
@property (weak, nonatomic) IBOutlet UILabel *goodsDesLabel;
@property (weak, nonatomic) IBOutlet UILabel *lastLabel;
@property (weak, nonatomic) IBOutlet UIView *bottomBgView;

@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *markLabel;
@end

@implementation OutOfTimeBuyItemCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.goodsDesLabel.font = MYFONT(12);
    self.markLabel.font = MYFONT(11);
    
    self.priceLabel.font = MYFONT(14);
    
    self.markLabel.textAlignment = NSTextAlignmentCenter;
    
    self.markLabel.layer.cornerRadius = 10;
    self.markLabel.layer.masksToBounds = YES;
    
//    self.lastLabel.attributedText = [self attributedStrin:@"138.8P"];
    
    self.bottomBgView.layer.cornerRadius = 15;
    
    self.bottomBgView.layer.masksToBounds = YES;
    
    self.contentView.backgroundColor = randomColor;
    
    
}

- (void)setModel:(MarketHSubModel *)model{
    
    _model = model;
    
    [self.topImageView sd_setImageWithURL:[NSURL URLWithString:_model.pic_cover_small] placeholderImage:nil];

    
    self.goodsDesLabel.text = _model.goods_name;
 
    
    self.priceLabel.text = [NSString stringWithFormat:@"%@",_model.promotion_price];
    
    self.lastLabel.attributedText = [self attributedStrin:[NSString stringWithFormat:@"%@P",_model.price]];
    
    
}




- (NSMutableAttributedString *)attributedStrin:(NSString *)str{

    
    NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:str];
    
    [attr addAttribute:NSFontAttributeName value:MYFONT(15) range:NSMakeRange(0, str.length)];
    [attr addAttribute:NSForegroundColorAttributeName value:darkGray range:NSMakeRange(0, str.length)];
    [attr addAttribute:NSStrikethroughStyleAttributeName value:@1 range:NSMakeRange(0, str.length)];
    //    [attr addAttribute:NSKernAttributeName value:@(0.5f) range:NSMakeRange(0, str.length)];
    
    return attr;
}

@end
